<template>
    <div class="publicpageview">
        <div class="topInput" v-if="type==''">
            <el-button class="buttons" type="primary" size="mini" @click="handleAddUser">统计</el-button>
            <el-form :rules='rules' :inline="true" :model="listQuery" size="mini" ref="addForm" label-width="170px">
                <div>
                    <el-form-item label="区：" prop="districtName" label-width="140px">
                        <el-input disabled v-model="listQuery.districtName"></el-input>
                    </el-form-item>
                    <el-form-item label="房管站：" prop="houseAdminName" label-width="140px">
                        <el-input disabled v-model="listQuery.houseAdminName"></el-input>
                    </el-form-item>

                    <el-form-item label="统计时间年：" prop="year" label-width="140px">
                        <el-input v-model="listQuery.year"></el-input>
                    </el-form-item>
                    <el-form-item label="统计时间月：" prop="mouth" label-width="140px">
                        <el-input v-model="listQuery.mouth"></el-input>
                    </el-form-item>
                    <div class="radios">
                        <div class="radioList">
                            <el-radio v-model="listQuery.check0" label="1">年计划汇总表</el-radio>
                        </div>
                        <div class="radioList">
                            <el-radio v-model="listQuery.check0" label="2">年计划地点明晰 </el-radio>
                        </div>
                    </div>
                    <div class="radios">
                        <div class="radioList">
                            <el-radio v-model="listQuery.check0" label="3">区年计划地点明晰</el-radio>
                        </div>
                        <div class="radioList">
                            <el-radio v-model="listQuery.check0" label="4">区年计划汇总</el-radio>
                        </div>
                    </div>
                    <div class="radios">
                        <div class="radioList">
                            <el-radio v-model="listQuery.check0" label="5">月统计表</el-radio>
                        </div>

                        <div class="radioList">
                            <el-radio v-model="listQuery.check0" label="6">月统计表2</el-radio>
                        </div>
                    </div>


                    <div class="radios">
                        <div class="radioList">
                            <el-radio v-model="listQuery.check0" label="7">区统计明晰表</el-radio>
                        </div>

                        <div class="radioList">
                            <el-radio v-model="listQuery.check0" label="8">区统计汇总表</el-radio>
                        </div>
                    </div>
                </div>
            </el-form>
        </div>

        <cybblist1 v-if="type==2" :blockobj="objData" @fanhui='fanhui'></cybblist1>
        <cybblist2 v-if="type==1" :blockobj="objData" @fanhui='fanhui'></cybblist2>
        <cybblist3 v-if="type==3" :blockobj="objData" @fanhui='fanhui'></cybblist3>
        <cybblist4 v-if="type==4" :blockobj="objData" @fanhui='fanhui'></cybblist4>
        <cybblist5 v-if="type==5" :blockobj="objData" @fanhui='fanhui'></cybblist5>
        <cybblist6 v-if="type==6" :blockobj="objData" @fanhui='fanhui'></cybblist6>
        <cybblist7 v-if="type==7" :blockobj="objData" @fanhui='fanhui'></cybblist7>
        <cybblist8 v-if="type==8" :blockobj="objData" @fanhui='fanhui'></cybblist8>
    </div>
</template>

<script>
import cybblist1 from './feicomponents/cybblist1.vue'
import cybblist5 from './feicomponents/cybblist5.vue'
import cybblist3 from './feicomponents/cybblist3.vue'
import cybblist2 from './feicomponents/cybblist2.vue'
import cybblist4 from './feicomponents/cybblist4.vue'
import cybblist6 from './feicomponents/cybblist6.vue'
import cybblist8 from './feicomponents/cybblist8.vue'
import cybblist7 from './feicomponents/cybblist7.vue'
import dayjs from 'dayjs'
import * as XLSX from 'xlsx'
import {
    blockGroupList,
    blockList,
    blockDetail,
    notHouse,
    industryReportOne,
    industryReportTwo,
    industryReportThree,
    industryReportFour,
    industryReportFive,
    industryReportSix,
    industryReportSeven,

    industryBuyerTwo,
    industryBuyerThree,
    industryBuyerFour,
    industryBuyerFive
} from '@/api/industry';
import { statisticsData1, statisticsData2, statisticsData4, statisticsData5, statisticsData7, statisticsData8, statisticsData6, statisticsData3 } from '@/api/repair'
export default {
    name: 'AccommodationManagementChanquanzhengjian',
    components: {
        cybblist1,
        cybblist2,
        cybblist3,
        cybblist4,
        cybblist5,
        cybblist6,
        cybblist7,
        cybblist8,
    },
    data() {
        return {
            listQuery: {
                check0: '',
                districtName: '',
                houseAdminName: '',
                aid: '',
                time: '',
                year: "",
                mouth: "",
            },
            type: '',
            objData: {},
            rules: {
                year: [
                    {
                        required: true,
                        message: '请输入年',
                        trigger: 'blur'
                    }
                ],
                mouth: [
                    {
                        required: true,
                        message: '请输入月',
                        trigger: 'blur'
                    }
                ],
            },
            guanpianList: [],
            blList: [],
            chanbieList: [],
            // 建筑形式
            jianzhuxingshiList: [],
            // 建筑形式明细
            jianzhuxingshimingxiList: [],
        }
    },

    computed: {},

    mounted() {
        this.listQuery.districtName = localStorage.getItem('userDname')
        this.listQuery.houseAdminName = localStorage.getItem('userHouseAdminName')
        this.listQuery.aid = localStorage.getItem('userHouseAdminId')
        // 遍历字典
        this.chanyeList = JSON.parse(localStorage.getItem('chanye'))
        this.chanyeList.forEach((item, index) => {
            if (item.classname == '产别') {
                item.classmidList.forEach((it, idx) => {
                    if (it.classmid == '产别') {
                        this.chanbieList = it.classdetailList
                    }
                })
            } else if (item.classname == '建筑形式') {
                this.jianzhuxingshiList = item.classmidList
            }
        })
        this.blockGroupList()
        this.blockList()
        // this.listQuery.check8 = new Date()
    },

    methods: {
        // 管片列表
        blockGroupList() {
            let data = {
                group: '',
                groupNumber: '',
                houseAdmin: '',
                pageNum: '',
                pageSize: 99999
            }
            this.listLoading = true
            blockGroupList(data).then((res) => {
                this.guanpianList = res.data.list
                this.listLoading = false
                // this.houseAdminList()
            })
        },
        blockList() {
            let data = {
                limit: 99999,
                page: 1
            }
            blockList(data).then((res) => {
                this.blList = res.data.list
            })
        },
        // 选择建筑形式
        jianzhuChange(value) {
            this.chanyeList.forEach((item, index) => {
                if (item.classname == '建筑形式') {
                    item.classmidList.forEach((it, idx) => {
                        if (value == '楼房' && it.classmid == '楼房') {
                            this.jianzhuxingshimingxiList = it.classdetailList
                        } else if (value == '平房' && it.classmid == '平房') {
                            this.jianzhuxingshimingxiList = it.classdetailList
                        }
                    })
                }
            })
        },
        blockChange(e) {
            //   this.blockid = e.blockid
            this.listQuery.check2 = e.blockno

            let data = {
                BlockID: e.blockid
            }
            blockDetail(data).then((res) => {
            })
        },
        handleAddUser() {
            this.$refs.addForm.validate((valid) => {
                if (valid) {
                    let data = this.listQuery
                    if (data.check0 == 1) {
                        statisticsData1(data).then(res => {
                            this.type = data.check0
                            this.objData = res.data
                        })
                    } else if (data.check0 == 2) {
                        statisticsData4(data).then(res => {
                            this.type = data.check0
                            this.objData = res.data
                        })
                    } else if (data.check0 == 3) {
                        statisticsData5(data).then(res => {
                            this.type = data.check0
                            this.objData = res.data
                        })
                    } else if (data.check0 == 4) {
                        statisticsData2(data).then(res => {
                            this.type = data.check0
                            this.objData = res.data
                        })
                    } else if (data.check0 == 5) {
                        statisticsData7(data).then(res => {
                            this.type = data.check0
                            this.objData = res.data
                        })
                    } else if (data.check0 == 6) {
                        statisticsData8(data).then(res => {
                            this.type = data.check0
                            this.objData = res.data
                        })
                    } else if (data.check0 == 7) {
                        statisticsData6(data).then(res => {
                            this.type = data.check0
                            this.objData = res.data
                        })
                    }

                    else if (data.check0 == 8) {
                        statisticsData3(data).then(res => {
                            this.type = data.check0
                            this.objData = res.data
                        })
                    }


                } else {
                    return false
                }
            })

        },
        fanhui() {
            this.type = ''
        }
    }
}
</script>
<style scoped>
.saveContent {
    width: 100%;
    display: flex;
    justify-content: end;
    margin-top: 20px;
    padding-bottom: 20px;
}

.title {
    color: #008c93;
    text-align: center;
    margin-bottom: 20px;
    font-weight: bold;
}

.cfguanpian {
    padding-bottom: 20px;
    color: #008c93;
    margin-bottom: 20px;
    font-weight: bold;
}

.title2 {
    color: #008c93;
    margin-bottom: 20px;
    font-weight: bold;
}

.tianjiaButton {
    border: 2px solid #008c93;
    background-color: #fff;
    color: #008c93;
}

::v-deep .el-input__inner {
    width: 130px;
}

::v-deep .publicpaginationview .el-input__inner {
    width: 100px;
}

::v-deep .publicpaginationview .is-in-pagination .el-input__inner {
    width: 50px;
}

.list {
    display: flex;
}

.topInput {
    width: 70%;
    height: 650px;
    margin: 0 auto;
    background-color: #fff;
    padding-top: 20px;
}

.radios {
    display: flex;
}

.radioList {
    width: 800px;
    margin-top: 30px;
    margin-left: 100px;
}

.buttons {
    margin: 20px 0 20px 90%;
    display: block;
}
</style>